<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <!-- 1. 创建一个根标签  -->
    <div id="root"></div>

    <!-- 2. 引入react库文件和babel 
    注意: 先引入react后引入react-dom. 因为react-dom依赖react
    -->
    <script
      crossorigin
      src="https://unpkg.com/react@17/umd/react.development.js"
    ></script>
    <script
      crossorigin
      src="https://unpkg.com/react-dom@17/umd/react-dom.development.js"
    ></script>
    <script src="./js/babel.min.js"></script>

    <!-- 3. 根据数据动态创建元素,最后渲染到页面上 -->
    <!-- type="text/babel" 作用: 让babel编译这个script里面的代码. 会将jsx编译成 React.createElement -->
    <script type="text/babel">
      const person = {
        name: '老陶',
        age: 58,
        description: 'lsp',
      }
      const div = (
        // jsx开始
        <div>
          {/*这是jsx的注释*/}
          {/*在jsx中,{}表示插值表达式,可以动态的插入数据*/}
          <h1>{person.name}</h1>
          <p>{person.age}</p>
          <div>{person.description}</div>
        </div>
        // jsx结束
      )
      ReactDOM.render(div, document.getElementById('root'))
    </script>
  </body>
</html>
